package com.study.common;

import java.util.ArrayList;
import java.util.List;

public class Util {

    public static List<String> stringToFixExpression(String s) {

        char[] chars = s.toCharArray();
        List<String> expressionList = new ArrayList<>();

        String numString = "";
        for (int i = 0; i < chars.length; i++) {
            while (i < chars.length && chars[i] >= 48 && chars[i] <= 57) {
                while (i < chars.length && chars[i] >= 48 && chars[i] <= 57) {
                    numString += chars[i];
                    i++;
                }
                expressionList.add(numString);
                numString="";
            }
            if (i<chars.length){
                expressionList.add(chars[i] + "");
            }

        }
        return expressionList;
    }

    public static int operatorLevel(String s){
        int operatorLevel = -1;
        switch (s){
            case "+":
                operatorLevel = 0;
                break;
            case "-":
                operatorLevel = 0;
                break;
            case "*":
                operatorLevel =1;
                break;
            case "/":
                operatorLevel = 1;
                break;
                default:
                    System.out.println("operator is does not exist");
        }
        return operatorLevel;

    }

}
